package day13;

import java.awt.Dimension;
import java.awt.GridLayout;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

/*
 * 登录界面
 */
public class JFrameDemo5 {
	public static void main(String[] args) {
		JFrame frame = new JFrame();
		JPanel panel = new JPanel();
		frame.add(panel);
		panel.setLayout(new GridLayout(3, 1));
		//界面第一行内容
		JPanel namePanel = new JPanel();
		JLabel nameLabel = new JLabel("用户名：");
		namePanel.add(nameLabel);
		JTextField nameTextField = new JTextField();
		nameTextField.setPreferredSize(new Dimension(100, 30));
		namePanel.add(nameTextField);
		//界面第二行内容
		JPanel passPanel = new JPanel();
		JLabel passLabel = new JLabel("密 码：");
		passPanel.add(passLabel);
		JTextField passTextField = new JTextField();
		passTextField.setPreferredSize(new Dimension(100, 30));
		passPanel.add(passTextField);
		//界面第三行内容
		JPanel loginPanel = new JPanel();
		JButton button1 = new JButton("登录");
		loginPanel.add(button1);
		JButton button2 = new JButton("取消");
		loginPanel.add(button2);
		//总的panel
		panel.add(namePanel);
		panel.add(passPanel);
		panel.add(loginPanel);
		frame.setSize(500, 300);
		frame.setLocation(450, 450);
		frame.setVisible(true);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}
}
